package com.lsh.oms.core.dao;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;

import javax.annotation.Resource;
import java.util.List;

public class SpringMybatisObjectFactory extends DefaultObjectFactory {

    @Resource
    private AutowireCapableBeanFactory beanFactory;

    @Override
    public <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
        T object = super.create(type, constructorArgTypes, constructorArgs);
        beanFactory.autowireBean(object);
        return object;
    }
}
